//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2007 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   FACT_AUDIT
// AUTHOR           :   Ray Guo 
// DATE CREATE      :   2007/09/10
// DESCRIPTION      :   a DAO file for the function, FACT_AUDIT
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2007/09/10   Ray Guo         1.0                 source is generated.
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package com.erp.app.compliance.factAudit.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.erp.app.common.ProjectConstants;
import com.erp.app.compliance.factAudit.criteria.FactAuditHdrSrchCriteria;
import com.erp.app.compliance.factAudit.pk.FactAuditHdrPk;
import com.erp.app.compliance.factAudit.pk.FactAuditProdCatPk;
import com.erp.app.compliance.factAudit.pk.FactAuditAttachPk;
import com.erp.app.compliance.factAudit.vo.FactAuditHdrVo;
import com.erp.app.compliance.factAudit.vo.FactAuditProdCatVo;
import com.erp.app.compliance.factAudit.vo.FactAuditAttachVo;

import com.erp.framework.exceptions.FindRecordException;
import com.erp.framework.model.criteria.SimpleBaseSrchCriteria;
import com.erp.framework.model.criteria.SimpleSearchMaintStyleSrchCriteria;
import com.erp.framework.model.dao.SimpleSearchMaintStyleDao;
import com.erp.framework.model.pk.SimpleBasePk;
import com.erp.framework.model.pk.SimpleSearchMaintStylePk;
import com.erp.framework.model.vo.ChildList;
import com.erp.framework.model.vo.SimpleBaseVo;
import com.erp.framework.model.vo.SimpleSearchMaintStyleVo;
import com.erp.framework.types.CustomBigDecimal;
import com.erp.framework.types.CustomBigInteger;
import com.erp.framework.types.CustomSqlDate;
import com.erp.framework.types.CustomTimestamp;
import com.erp.framework.types.CustomUtilDate;
import com.erp.framework.util.DateTimeUtil;
import com.erp.framework.util.NumberUtil;
import com.erp.framework.util.CommonUtil;
import com.erp.framework.util.logger.Logger;

/**
* <p>A <strong>DAO</strong>(Data Access Object) abstracts and encapsulates
* all access to the persistent store.  The DAO manages the connection with the
* data source to obtain and store data.  Also, the DAO implements
* the access mechanism required to work with the data source,
* and always provides a uniform API to its clients.
*
* @author          Ray Guo 
* @version 1.0     2007/09/10
* @since           FrameWork 1.0
*
*/
public class FactAuditHdrDao extends SimpleSearchMaintStyleDao {

	/**
	* Returns the SQL select statement.
	* @param         obj     the searching criteria
	* @return        a string containing sql query
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlQuery(SimpleBaseSrchCriteria obj) {
		String sql = FactAuditCommonDao.getHdrSqlQuery(obj);

		return sql;
	}


	/**
	* Returns the SQL select statement.
	* @return        a string containing sql query
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlSelectByPrimaryKey(){

		return sqlFind();
	}

	/**
	* Sets the values of a result set to a pk
	* @param         pStmt   the incoming prepared statement
	* @param         pk      the searching primary key
	* @return        a vo containing the result set values
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected void setValuesForSelectByPrimaryKey(PreparedStatement pStmt, SimpleBasePk pk) throws SQLException{

		setValuesForFind(pStmt, pk);
	}

	/**
	* Returns the constructed model from a result set.
	* @param         rs     the incoming result set
	* @return        a constructed VO from the result set
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected SimpleBaseVo getModelForSelectByPrimarKey(ResultSet rs) throws SQLException {

		return getResultSetValues(rs);
	}


	/**
	* Returns the SQL select statement.
	* @param         criteria     the searching criteria
	* @return        a string containing sql query
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlSelectByCriteria(SimpleBaseSrchCriteria criteria) {

		return sqlQuery(criteria);
	}

	/**
	* Returns the constructed model from a result set.
	* @param         rs     the incoming result set
	* @return        a constructed VO from the result set
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected SimpleBaseVo getModelForSelectByCriteria(ResultSet rs) throws SQLException {

		return getResultSetValues(rs);
	}

	/**
	* Returns the constructed primary key from a result set.
	* @param         rs     the incoming result set
	* @return        a constructed PK from the result set
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected SimpleBasePk getPkForSelectByCriteria(ResultSet rs) throws SQLException {

		FactAuditHdrPk pk = new FactAuditHdrPk(rs.getString("COMPANY_CODE"), rs.getString("AUDIT_NO"));
		return pk;
	}


	/**
	* Returns an array list of child VOs by the parent
	* @param         parent   the incoming parent VO
	* @param         conn     the database connection
	* @return        an array list of child VOs
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	public ChildList selectByParent(SimpleBaseVo parent, Connection conn)
		throws FindRecordException {

		return null;
	}

	/**
	* Constructs a string of SQL insert statement
	* @return        a string of SQL insert statement
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlInsert() {

		String sql = "INSERT INTO T_FACT_AUDIT_HDR ("
			+ "COMPANY_CODE, AUDIT_NO, AUDIT_DATE, ISSUE_DATE, STATUS, "
			+ "INSPECT_CODE, PERIOD_DATE, EXPIRY_DATE, CUST_CODE, IS_CONTINUE, "
			+ "DEPT_CODE, VENDOR_CODE, VENDOR_NAME, FACT_CODE, FACT_NAME, "
			+ "FACT_ADDRESS1, FACT_ADDRESS2, FACT_ADDRESS3, FACT_ADDRESS_COUNTRY, FACT_LOCATION, "
			+ "CONTACT_PERSON, CONTACT_PERSON_TITLE, QA_CONTACT, QA_CONTACT_TITLE, CAPITAL, "
			+ "LEGAL_STATUS, TEL_NO, TEL_NO_COUNTRY, TEL_NO_AREA, TEL_NO_EXT, "
			+ "FAX_NO, FAX_NO_COUNTRY, FAX_NO_AREA, POSTAL_CODE, EMAIL, "
			+ "FOUND_DATE, BUSINESS_YEAR, HAS_VENDOR_QUOTA, VENDOR_QUOTA, QUOTA_CATE, "
			+ "FACT_ENVIR_LAW, FACT_OCCUP_LAW, FACT_FIRE_HOSE, FACT_AID_KIT, FACT_WORKDAY_LAW, "
			+ "FACT_MIN_AGE_LAW, FACT_EMERGEN_EXIST, FACT_EMERGEN_EXIST_LOCK, FACT_EMERGEN_EXIST_ACCESSIBLE, FACT_SUBCONTRACT, "
			+ "FACT_SUBCONTRACT_PROVIDE_HOUSE, HOUSE_ENVIR_LAW, HOUSE_HEAL_SAFE_LAW, HOUSE_FIRE_SAFE_LAW, FACT_PEOPLE_NUM, "
			+ "FACT_WORKER_NUM, FACT_EMPLOY_PRI_LANG, FACT_MANAGE_PRI_LANG, FACT_ORDER_CAPACITY, RD_FACI, "
			+ "SHOW_ROOM, MAKE_FACI, IT_FACI, INJECT_MOLDING, SPRAY_PAINTING, "
			+ "DIE_CASTING, HAND_PAINTING, RESIN_CASTING, FABRICATION, STAMPING, "
			+ "SONIC_WELDING, ROTA_CASTING, SOLDERING, BLOW_MOLDING, WASHING, "
			+ "CUTTING, BUTTONING, SEWING, DIP_COATING, PRESSING, "
			+ "PLATING, STITCHING, LAMINATING, TEMPO_PRINTING, SPEC_EQUIP, "
			+ "FACT_PROD_LINE, FACT_MET_COMPLIANCE, CUST_MET_COMPLIANCE, OTH_NAME_1, OTH_PROD_1, "
			+ "OTH_NAME_2, OTH_PROD_2, OTH_NAME_3, OTH_PROD_3, OTH_MTH_CAP, "
			+ "OTH_MIN_ODR, OTH_ODR_LEADTIME, OTH_WORKER_NUM, OTH_VER_MAKER, OTH_SV_NUM, "
			+ "OTH_QA_NUM, OTH_REMARK, OTH_MIN_QA_CENTER) "
			+ "VALUES ("
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?, ?, ?, "
			+ "?, ?, ?)";
		return sql;
	}

	/**
	* Sets the values for a SQL insert or update statement.
	* @param         pStmt   the incoming prepared statement
	* @param         obj     the incoming VO
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected void setValuesForInsertAndModify(PreparedStatement pStmt, Object obj, String opType)
		throws SQLException {

		FactAuditHdrVo vo = (FactAuditHdrVo) obj;
		int i = 1;

		pStmt.setString(i++, vo.getCompanyCode());
		pStmt.setString(i++, vo.getAuditNo());
		setNullableDate(pStmt, i++, vo.getHdrAuditDate());
		setNullableDate(pStmt, i++, vo.getHdrIssueDate());
		setNullableString(pStmt, i++, vo.getHdrStatus());
		setNullableString(pStmt, i++, vo.getHdrInspectCode());
		setNullableDate(pStmt, i++, vo.getHdrPeriodDate());
		setNullableDate(pStmt, i++, vo.getHdrExpiryDate());
		setNullableString(pStmt, i++, vo.getHdrCustCode());
		setNullableString(pStmt, i++, vo.getHdrIsContinue());
		setNullableString(pStmt, i++, vo.getHdrDeptCode());
		setNullableString(pStmt, i++, vo.getHdrVendorCode());
		setNullableString(pStmt, i++, vo.getHdrVendorName());
		setNullableString(pStmt, i++, vo.getHdrFactCode());
		setNullableString(pStmt, i++, vo.getHdrFactName());
		setNullableString(pStmt, i++, vo.getHdrFactAddress1());
		setNullableString(pStmt, i++, vo.getHdrFactAddress2());
		setNullableString(pStmt, i++, vo.getHdrFactAddress3());
		setNullableString(pStmt, i++, vo.getHdrFactAddressCountry());
		setNullableString(pStmt, i++, vo.getHdrFactLocation());
		setNullableString(pStmt, i++, vo.getHdrContactPerson());
		setNullableString(pStmt, i++, vo.getHdrContactPersonTitle());
		setNullableString(pStmt, i++, vo.getHdrQaContact());
		setNullableString(pStmt, i++, vo.getHdrQaContactTitle());
		setNullableBigDecimal(pStmt, i++, vo.getHdrCapital());
		setNullableString(pStmt, i++, vo.getHdrLegalStatus());
		setNullableString(pStmt, i++, vo.getHdrTelNo());
		setNullableString(pStmt, i++, vo.getHdrTelNoCountry());
		setNullableString(pStmt, i++, vo.getHdrTelNoArea());
		setNullableString(pStmt, i++, vo.getHdrTelNoExt());
		setNullableString(pStmt, i++, vo.getHdrFaxNo());
		setNullableString(pStmt, i++, vo.getHdrFaxNoCountry());
		setNullableString(pStmt, i++, vo.getHdrFaxNoArea());
		setNullableString(pStmt, i++, vo.getHdrPostalCode());
		setNullableString(pStmt, i++, vo.getHdrEmail());
		setNullableDate(pStmt, i++, vo.getHdrFoundDate());
		setNullableBigDecimal(pStmt, i++, vo.getHdrBusinessYear());
		setNullableString(pStmt, i++, vo.getHdrHasVendorQuota());
		setNullableString(pStmt, i++, vo.getHdrVendorQuota());
		setNullableString(pStmt, i++, vo.getHdrQuotaCate());
		setNullableString(pStmt, i++, vo.getHdrFactEnvirLaw());
		setNullableString(pStmt, i++, vo.getHdrFactOccupLaw());
		setNullableString(pStmt, i++, vo.getHdrFactFireHose());
		setNullableString(pStmt, i++, vo.getHdrFactAidKit());
		setNullableString(pStmt, i++, vo.getHdrFactWorkdayLaw());
		setNullableString(pStmt, i++, vo.getHdrFactMinAgeLaw());
		setNullableString(pStmt, i++, vo.getHdrFactEmergenExist());
		setNullableString(pStmt, i++, vo.getHdrFactEmergenExistLock());
		setNullableString(pStmt, i++, vo.getHdrFactEmergenExistAccessible());
		setNullableString(pStmt, i++, vo.getHdrFactSubcontract());
		setNullableString(pStmt, i++, vo.getHdrFactSubcontractProvideHouse());
		setNullableString(pStmt, i++, vo.getHdrHouseEnvirLaw());
		setNullableString(pStmt, i++, vo.getHdrHouseHealSafeLaw());
		setNullableString(pStmt, i++, vo.getHdrHouseFireSafeLaw());
		setNullableBigDecimal(pStmt, i++, vo.getHdrFactPeopleNum());
		setNullableBigDecimal(pStmt, i++, vo.getHdrFactWorkerNum());
		setNullableString(pStmt, i++, vo.getHdrFactEmployPriLang());
		setNullableString(pStmt, i++, vo.getHdrFactManagePriLang());
		setNullableBigDecimal(pStmt, i++, vo.getHdrFactOrderCapacity());
		setNullableString(pStmt, i++, vo.getHdrRdFaci());
		setNullableString(pStmt, i++, vo.getHdrShowRoom());
		setNullableString(pStmt, i++, vo.getHdrMakeFaci());
		setNullableString(pStmt, i++, vo.getHdrItFaci());
		setNullableString(pStmt, i++, vo.getHdrInjectMolding());
		setNullableString(pStmt, i++, vo.getHdrSprayPainting());
		setNullableString(pStmt, i++, vo.getHdrDieCasting());
		setNullableString(pStmt, i++, vo.getHdrHandPainting());
		setNullableString(pStmt, i++, vo.getHdrResinCasting());
		setNullableString(pStmt, i++, vo.getHdrFabrication());
		setNullableString(pStmt, i++, vo.getHdrStamping());
		setNullableString(pStmt, i++, vo.getHdrSonicWelding());
		setNullableString(pStmt, i++, vo.getHdrRotaCasting());
		setNullableString(pStmt, i++, vo.getHdrSoldering());
		setNullableString(pStmt, i++, vo.getHdrBlowMolding());
		setNullableString(pStmt, i++, vo.getHdrWashing());
		setNullableString(pStmt, i++, vo.getHdrCutting());
		setNullableString(pStmt, i++, vo.getHdrButtoning());
		setNullableString(pStmt, i++, vo.getHdrSewing());
		setNullableString(pStmt, i++, vo.getHdrDipCoating());
		setNullableString(pStmt, i++, vo.getHdrPressing());
		setNullableString(pStmt, i++, vo.getHdrPlating());
		setNullableString(pStmt, i++, vo.getHdrStitching());
		setNullableString(pStmt, i++, vo.getHdrLaminating());
		setNullableString(pStmt, i++, vo.getHdrTempoPrinting());
		setNullableString(pStmt, i++, vo.getHdrSpecEquip());
		setNullableString(pStmt, i++, vo.getHdrFactProdLine());
		setNullableString(pStmt, i++, vo.getHdrFactMetCompliance());
		setNullableString(pStmt, i++, vo.getHdrCustMetCompliance());
		setNullableString(pStmt, i++, vo.getHdrOthName1());
		setNullableString(pStmt, i++, vo.getHdrOthProd1());
		setNullableString(pStmt, i++, vo.getHdrOthName2());
		setNullableString(pStmt, i++, vo.getHdrOthProd2());
		setNullableString(pStmt, i++, vo.getHdrOthName3());
		setNullableString(pStmt, i++, vo.getHdrOthProd3());
		setNullableBigDecimal(pStmt, i++, vo.getHdrOthMthCap());
		setNullableBigDecimal(pStmt, i++, vo.getHdrOthMinOdr());
		setNullableBigDecimal(pStmt, i++, vo.getHdrOthOdrLeadtime());
		setNullableBigDecimal(pStmt, i++, vo.getHdrOthWorkerNum());
		setNullableString(pStmt, i++, vo.getHdrOthVerMaker());
		setNullableBigDecimal(pStmt, i++, vo.getHdrOthSvNum());
		setNullableBigDecimal(pStmt, i++, vo.getHdrOthQaNum());
		setNullableString(pStmt, i++, vo.getHdrOthRemark());
		setNullableString(pStmt, i++, vo.getHdrOthMinQaCenter());

		if(ProjectConstants.DB_OP_UPDATE.equals(opType)){
			pStmt.setString(i++, vo.getCompanyCode());
			pStmt.setString(i++, vo.getAuditNo());
			setNullableTimestamp(pStmt, i++, vo.getUpdateDate());
		}
	}

	/**
	* Sets the values for a SQL insert statement.
	* @param         pStmt   the incoming prepared statement
	* @param         obj     the incoming VO
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected void setValuesForInsert(PreparedStatement pStmt, Object obj)
		throws SQLException {

		setValuesForInsertAndModify(pStmt, obj, ProjectConstants.DB_OP_INSERT);
	}

	/**
	* Constructs a string of SQL update statement
	* @return        a string of SQL update statement
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlUpdate() {

		String sql = "UPDATE T_FACT_AUDIT_HDR SET COMPANY_CODE=?, AUDIT_NO=?, AUDIT_DATE=?, ISSUE_DATE=?, STATUS=?, "
			+ "INSPECT_CODE=?, PERIOD_DATE=?, EXPIRY_DATE=?, CUST_CODE=?, IS_CONTINUE=?, "
			+ "DEPT_CODE=?, VENDOR_CODE=?, VENDOR_NAME=?, FACT_CODE=?, FACT_NAME=?, "
			+ "FACT_ADDRESS1=?, FACT_ADDRESS2=?, FACT_ADDRESS3=?, FACT_ADDRESS_COUNTRY=?, FACT_LOCATION=?, "
			+ "CONTACT_PERSON=?, CONTACT_PERSON_TITLE=?, QA_CONTACT=?, QA_CONTACT_TITLE=?, CAPITAL=?, "
			+ "LEGAL_STATUS=?, TEL_NO=?, TEL_NO_COUNTRY=?, TEL_NO_AREA=?, TEL_NO_EXT=?, "
			+ "FAX_NO=?, FAX_NO_COUNTRY=?, FAX_NO_AREA=?, POSTAL_CODE=?, EMAIL=?, "
			+ "FOUND_DATE=?, BUSINESS_YEAR=?, HAS_VENDOR_QUOTA=?, VENDOR_QUOTA=?, QUOTA_CATE=?, "
			+ "FACT_ENVIR_LAW=?, FACT_OCCUP_LAW=?, FACT_FIRE_HOSE=?, FACT_AID_KIT=?, FACT_WORKDAY_LAW=?, "
			+ "FACT_MIN_AGE_LAW=?, FACT_EMERGEN_EXIST=?, FACT_EMERGEN_EXIST_LOCK=?, FACT_EMERGEN_EXIST_ACCESSIBLE=?, FACT_SUBCONTRACT=?, "
			+ "FACT_SUBCONTRACT_PROVIDE_HOUSE=?, HOUSE_ENVIR_LAW=?, HOUSE_HEAL_SAFE_LAW=?, HOUSE_FIRE_SAFE_LAW=?, FACT_PEOPLE_NUM=?, "
			+ "FACT_WORKER_NUM=?, FACT_EMPLOY_PRI_LANG=?, FACT_MANAGE_PRI_LANG=?, FACT_ORDER_CAPACITY=?, RD_FACI=?, "
			+ "SHOW_ROOM=?, MAKE_FACI=?, IT_FACI=?, INJECT_MOLDING=?, SPRAY_PAINTING=?, "
			+ "DIE_CASTING=?, HAND_PAINTING=?, RESIN_CASTING=?, FABRICATION=?, STAMPING=?, "
			+ "SONIC_WELDING=?, ROTA_CASTING=?, SOLDERING=?, BLOW_MOLDING=?, WASHING=?, "
			+ "CUTTING=?, BUTTONING=?, SEWING=?, DIP_COATING=?, PRESSING=?, "
			+ "PLATING=?, STITCHING=?, LAMINATING=?, TEMPO_PRINTING=?, SPEC_EQUIP=?, "
			+ "FACT_PROD_LINE=?, FACT_MET_COMPLIANCE=?, CUST_MET_COMPLIANCE=?, OTH_NAME_1=?, OTH_PROD_1=?, "
			+ "OTH_NAME_2=?, OTH_PROD_2=?, OTH_NAME_3=?, OTH_PROD_3=?, OTH_MTH_CAP=?, "
			+ "OTH_MIN_ODR=?, OTH_ODR_LEADTIME=?, OTH_WORKER_NUM=?, OTH_VER_MAKER=?, OTH_SV_NUM=?, "
			+ "OTH_QA_NUM=?, OTH_REMARK=?, OTH_MIN_QA_CENTER=? "
			+ "WHERE COMPANY_CODE=? AND AUDIT_NO=? "
			+ "AND (UPDATE_DATE IS NULL OR UPDATE_DATE = ?) ";
		return sql;
	}

	/**
	* Sets the values for a SQL update statement.
	* @param         pStmt   the incoming prepared statement
	* @param         obj     the incoming VO
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected void setValuesForModify(PreparedStatement pStmt, Object obj)
		throws SQLException {

		setValuesForInsertAndModify(pStmt, obj, ProjectConstants.DB_OP_UPDATE);
	}

	/**
	* Constructs a string of SQL delete statement
	* @return        a string of SQL update statement
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlDelete() {
		String sql = "DELETE FROM T_FACT_AUDIT_HDR WHERE COMPANY_CODE=? AND AUDIT_NO=? ";

		return sql;
	}

	/**
	* Sets the values for a SQL delete statement.
	* @param         pStmt   the incoming prepared statement
	* @param         obj     the incoming VO
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected void setValuesForDelete(PreparedStatement pStmt, Object obj)
		throws SQLException {

		FactAuditHdrVo vo = (FactAuditHdrVo) obj;
		int i = 1;

		pStmt.setString(i++, vo.getCompanyCode());
		pStmt.setString(i++, vo.getAuditNo());
	}

	/**
	* Constructs a string of SQL select statement
	* @return        a string of SQL select statement
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlFind() {

		String sql = "SELECT COMPANY_CODE, AUDIT_NO, AUDIT_DATE, ISSUE_DATE, STATUS, "
			+ "INSPECT_CODE, PERIOD_DATE, EXPIRY_DATE, CUST_CODE, IS_CONTINUE, "
			+ "DEPT_CODE, VENDOR_CODE, VENDOR_NAME, FACT_CODE, FACT_NAME, "
			+ "FACT_ADDRESS1, FACT_ADDRESS2, FACT_ADDRESS3, FACT_ADDRESS_COUNTRY, FACT_LOCATION, "
			+ "CONTACT_PERSON, CONTACT_PERSON_TITLE, QA_CONTACT, QA_CONTACT_TITLE, CAPITAL, "
			+ "LEGAL_STATUS, TEL_NO, TEL_NO_COUNTRY, TEL_NO_AREA, TEL_NO_EXT, "
			+ "FAX_NO, FAX_NO_COUNTRY, FAX_NO_AREA, POSTAL_CODE, EMAIL, "
			+ "FOUND_DATE, BUSINESS_YEAR, HAS_VENDOR_QUOTA, VENDOR_QUOTA, QUOTA_CATE, "
			+ "FACT_ENVIR_LAW, FACT_OCCUP_LAW, FACT_FIRE_HOSE, FACT_AID_KIT, FACT_WORKDAY_LAW, "
			+ "FACT_MIN_AGE_LAW, FACT_EMERGEN_EXIST, FACT_EMERGEN_EXIST_LOCK, FACT_EMERGEN_EXIST_ACCESSIBLE, FACT_SUBCONTRACT, "
			+ "FACT_SUBCONTRACT_PROVIDE_HOUSE, HOUSE_ENVIR_LAW, HOUSE_HEAL_SAFE_LAW, HOUSE_FIRE_SAFE_LAW, FACT_PEOPLE_NUM, "
			+ "FACT_WORKER_NUM, FACT_EMPLOY_PRI_LANG, FACT_MANAGE_PRI_LANG, FACT_ORDER_CAPACITY, RD_FACI, "
			+ "SHOW_ROOM, MAKE_FACI, IT_FACI, INJECT_MOLDING, SPRAY_PAINTING, "
			+ "DIE_CASTING, HAND_PAINTING, RESIN_CASTING, FABRICATION, STAMPING, "
			+ "SONIC_WELDING, ROTA_CASTING, SOLDERING, BLOW_MOLDING, WASHING, "
			+ "CUTTING, BUTTONING, SEWING, DIP_COATING, PRESSING, "
			+ "PLATING, STITCHING, LAMINATING, TEMPO_PRINTING, SPEC_EQUIP, "
			+ "FACT_PROD_LINE, FACT_MET_COMPLIANCE, CUST_MET_COMPLIANCE, OTH_NAME_1, OTH_PROD_1, "
			+ "OTH_NAME_2, OTH_PROD_2, OTH_NAME_3, OTH_PROD_3, OTH_MTH_CAP, "
			+ "OTH_MIN_ODR, OTH_ODR_LEADTIME, OTH_WORKER_NUM, OTH_VER_MAKER, OTH_SV_NUM, "
			+ "OTH_QA_NUM, OTH_REMARK, OTH_MIN_QA_CENTER "
			+ "FROM T_FACT_AUDIT_HDR "
			+ "WHERE COMPANY_CODE=? AND AUDIT_NO=? "
			+ "ORDER BY COMPANY_CODE, AUDIT_NO";
		return sql;
	}

	/**
	* Sets the values for a SQL select statement for finding by primary key.
	* @param         pStmt   the incoming prepared statement
	* @param         obj     the incoming PK
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected void setValuesForFind(PreparedStatement pStmt, Object obj)
		throws SQLException {

		FactAuditHdrPk pk = (FactAuditHdrPk) obj;
		int i = 1;

		pStmt.setString(i++, pk.getCompanyCode());
		pStmt.setString(i++, pk.getAuditNo());
	}

	/**
	* Constructs a string of SQL select statement
	* @return        a string of SQL select statement
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected String sqlList() {

		return null;
	}

	/**
	* Sets the values for a SQL select statement for finding child tables.
	* @param         pStmt   the incoming prepared statement
	* @param         obj     the incoming parent PK
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected void setValuesForList(PreparedStatement pStmt, Object obj)
		throws SQLException {

	}

	/**
	* Sets the values of a result set to a vo for a search screen
	* @param         rs   the incoming result set
	* @return        a vo containing the result set values
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected SimpleBaseVo getSearchResultSetValues(ResultSet rs) throws SQLException {


		return FactAuditCommonDao.getHdrSearchResultSetValues(rs);
	}

	/**
	* Sets the values of a result set to a vo
	* @param         rs   the incoming result set
	* @return        a vo containing the result set values
	*
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	protected SimpleBaseVo getResultSetValues(ResultSet rs) throws SQLException {

		FactAuditHdrVo vo = new FactAuditHdrVo();

		vo.setCompanyCode(rs.getString("COMPANY_CODE"));
		vo.setAuditNo(rs.getString("AUDIT_NO"));
		vo.setHdrAuditDate(CustomSqlDate.customize(rs.getDate("AUDIT_DATE")));
		vo.setHdrIssueDate(CustomSqlDate.customize(rs.getDate("ISSUE_DATE")));
		vo.setHdrStatus(rs.getString("STATUS"));
		vo.setHdrInspectCode(rs.getString("INSPECT_CODE"));
		vo.setHdrPeriodDate(CustomSqlDate.customize(rs.getDate("PERIOD_DATE")));
		vo.setHdrExpiryDate(CustomSqlDate.customize(rs.getDate("EXPIRY_DATE")));
		vo.setHdrCustCode(rs.getString("CUST_CODE"));
		vo.setHdrIsContinue(rs.getString("IS_CONTINUE"));
		vo.setHdrDeptCode(rs.getString("DEPT_CODE"));
		vo.setHdrVendorCode(rs.getString("VENDOR_CODE"));
		vo.setHdrVendorName(rs.getString("VENDOR_NAME"));
		vo.setHdrFactCode(rs.getString("FACT_CODE"));
		vo.setHdrFactName(rs.getString("FACT_NAME"));
		vo.setHdrFactAddress1(rs.getString("FACT_ADDRESS1"));
		vo.setHdrFactAddress2(rs.getString("FACT_ADDRESS2"));
		vo.setHdrFactAddress3(rs.getString("FACT_ADDRESS3"));
		vo.setHdrFactAddressCountry(rs.getString("FACT_ADDRESS_COUNTRY"));
		vo.setHdrFactLocation(rs.getString("FACT_LOCATION"));
		vo.setHdrContactPerson(rs.getString("CONTACT_PERSON"));
		vo.setHdrContactPersonTitle(rs.getString("CONTACT_PERSON_TITLE"));
		vo.setHdrQaContact(rs.getString("QA_CONTACT"));
		vo.setHdrQaContactTitle(rs.getString("QA_CONTACT_TITLE"));
		vo.setHdrCapital(CustomBigDecimal.customize(rs.getBigDecimal("CAPITAL")));
		vo.setHdrLegalStatus(rs.getString("LEGAL_STATUS"));
		vo.setHdrTelNo(rs.getString("TEL_NO"));
		vo.setHdrTelNoCountry(rs.getString("TEL_NO_COUNTRY"));
		vo.setHdrTelNoArea(rs.getString("TEL_NO_AREA"));
		vo.setHdrTelNoExt(rs.getString("TEL_NO_EXT"));
		vo.setHdrFaxNo(rs.getString("FAX_NO"));
		vo.setHdrFaxNoCountry(rs.getString("FAX_NO_COUNTRY"));
		vo.setHdrFaxNoArea(rs.getString("FAX_NO_AREA"));
		vo.setHdrPostalCode(rs.getString("POSTAL_CODE"));
		vo.setHdrEmail(rs.getString("EMAIL"));
		vo.setHdrFoundDate(CustomSqlDate.customize(rs.getDate("FOUND_DATE")));
		vo.setHdrBusinessYear(CustomBigDecimal.customize(rs.getBigDecimal("BUSINESS_YEAR")));
		vo.setHdrHasVendorQuota(rs.getString("HAS_VENDOR_QUOTA"));
		vo.setHdrVendorQuota(rs.getString("VENDOR_QUOTA"));
		vo.setHdrQuotaCate(rs.getString("QUOTA_CATE"));
		vo.setHdrFactEnvirLaw(rs.getString("FACT_ENVIR_LAW"));
		vo.setHdrFactOccupLaw(rs.getString("FACT_OCCUP_LAW"));
		vo.setHdrFactFireHose(rs.getString("FACT_FIRE_HOSE"));
		vo.setHdrFactAidKit(rs.getString("FACT_AID_KIT"));
		vo.setHdrFactWorkdayLaw(rs.getString("FACT_WORKDAY_LAW"));
		vo.setHdrFactMinAgeLaw(rs.getString("FACT_MIN_AGE_LAW"));
		vo.setHdrFactEmergenExist(rs.getString("FACT_EMERGEN_EXIST"));
		vo.setHdrFactEmergenExistLock(rs.getString("FACT_EMERGEN_EXIST_LOCK"));
		vo.setHdrFactEmergenExistAccessible(rs.getString("FACT_EMERGEN_EXIST_ACCESSIBLE"));
		vo.setHdrFactSubcontract(rs.getString("FACT_SUBCONTRACT"));
		vo.setHdrFactSubcontractProvideHouse(rs.getString("FACT_SUBCONTRACT_PROVIDE_HOUSE"));
		vo.setHdrHouseEnvirLaw(rs.getString("HOUSE_ENVIR_LAW"));
		vo.setHdrHouseHealSafeLaw(rs.getString("HOUSE_HEAL_SAFE_LAW"));
		vo.setHdrHouseFireSafeLaw(rs.getString("HOUSE_FIRE_SAFE_LAW"));
		vo.setHdrFactPeopleNum(CustomBigDecimal.customize(rs.getBigDecimal("FACT_PEOPLE_NUM")));
		vo.setHdrFactWorkerNum(CustomBigDecimal.customize(rs.getBigDecimal("FACT_WORKER_NUM")));
		vo.setHdrFactEmployPriLang(rs.getString("FACT_EMPLOY_PRI_LANG"));
		vo.setHdrFactManagePriLang(rs.getString("FACT_MANAGE_PRI_LANG"));
		vo.setHdrFactOrderCapacity(CustomBigDecimal.customize(rs.getBigDecimal("FACT_ORDER_CAPACITY")));
		vo.setHdrRdFaci(rs.getString("RD_FACI"));
		vo.setHdrShowRoom(rs.getString("SHOW_ROOM"));
		vo.setHdrMakeFaci(rs.getString("MAKE_FACI"));
		vo.setHdrItFaci(rs.getString("IT_FACI"));
		vo.setHdrInjectMolding(rs.getString("INJECT_MOLDING"));
		vo.setHdrSprayPainting(rs.getString("SPRAY_PAINTING"));
		vo.setHdrDieCasting(rs.getString("DIE_CASTING"));
		vo.setHdrHandPainting(rs.getString("HAND_PAINTING"));
		vo.setHdrResinCasting(rs.getString("RESIN_CASTING"));
		vo.setHdrFabrication(rs.getString("FABRICATION"));
		vo.setHdrStamping(rs.getString("STAMPING"));
		vo.setHdrSonicWelding(rs.getString("SONIC_WELDING"));
		vo.setHdrRotaCasting(rs.getString("ROTA_CASTING"));
		vo.setHdrSoldering(rs.getString("SOLDERING"));
		vo.setHdrBlowMolding(rs.getString("BLOW_MOLDING"));
		vo.setHdrWashing(rs.getString("WASHING"));
		vo.setHdrCutting(rs.getString("CUTTING"));
		vo.setHdrButtoning(rs.getString("BUTTONING"));
		vo.setHdrSewing(rs.getString("SEWING"));
		vo.setHdrDipCoating(rs.getString("DIP_COATING"));
		vo.setHdrPressing(rs.getString("PRESSING"));
		vo.setHdrPlating(rs.getString("PLATING"));
		vo.setHdrStitching(rs.getString("STITCHING"));
		vo.setHdrLaminating(rs.getString("LAMINATING"));
		vo.setHdrTempoPrinting(rs.getString("TEMPO_PRINTING"));
		vo.setHdrSpecEquip(rs.getString("SPEC_EQUIP"));
		vo.setHdrFactProdLine(rs.getString("FACT_PROD_LINE"));
		vo.setHdrFactMetCompliance(rs.getString("FACT_MET_COMPLIANCE"));
		vo.setHdrCustMetCompliance(rs.getString("CUST_MET_COMPLIANCE"));
		vo.setHdrOthName1(rs.getString("OTH_NAME_1"));
		vo.setHdrOthProd1(rs.getString("OTH_PROD_1"));
		vo.setHdrOthName2(rs.getString("OTH_NAME_2"));
		vo.setHdrOthProd2(rs.getString("OTH_PROD_2"));
		vo.setHdrOthName3(rs.getString("OTH_NAME_3"));
		vo.setHdrOthProd3(rs.getString("OTH_PROD_3"));
		vo.setHdrOthMthCap(CustomBigDecimal.customize(rs.getBigDecimal("OTH_MTH_CAP")));
		vo.setHdrOthMinOdr(CustomBigDecimal.customize(rs.getBigDecimal("OTH_MIN_ODR")));
		vo.setHdrOthOdrLeadtime(CustomBigDecimal.customize(rs.getBigDecimal("OTH_ODR_LEADTIME")));
		vo.setHdrOthWorkerNum(CustomBigDecimal.customize(rs.getBigDecimal("OTH_WORKER_NUM")));
		vo.setHdrOthVerMaker(rs.getString("OTH_VER_MAKER"));
		vo.setHdrOthSvNum(CustomBigDecimal.customize(rs.getBigDecimal("OTH_SV_NUM")));
		vo.setHdrOthQaNum(CustomBigDecimal.customize(rs.getBigDecimal("OTH_QA_NUM")));
		vo.setHdrOthRemark(rs.getString("OTH_REMARK"));
		vo.setHdrOthMinQaCenter(rs.getString("OTH_MIN_QA_CENTER"));

		return vo;
	}

}
